﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.Xml.Serialization;

namespace Tomahawk.Runtime.Rendering.Particles
{
    public class ParticleSourceSegment : ParticleSource
    {
        #region Serializable Properties
        [XmlElement("Length")]
        public float length = 0.0f;
        [XmlElement("Velocity")]
        public Vector3 velocity = Vector3.Zero;
        #endregion

        public override Vector3 GenerateParticlePosition(ref Matrix worldMatrix)
        {
            double distance = -0.5 * length + ParticleSystem.Random.NextDouble() * length;

            Vector3 position = Vector3.Zero;
            position.X = (float) distance;

            return Vector3.Transform(Vector3.Zero, worldMatrix);
        }

        public override Vector3 GenerateParticleVelocity(ref Matrix worldMatrix)
        {
            return Vector3.TransformNormal(AddNoiseToVelocity(ref velocity), worldMatrix);
        }
    }
}
